<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="plugins/ztree/js/jquery-1.4.4.min.js"></script>
    <script src="plugins/ztree/js/jquery.ztree.all-3.5.js"></script>
    <link rel="stylesheet" href="plugins/ztree/css/zTreeStyle/zTreeStyle.css">
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
    var zTreeObj;
    // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）
    var setting = {
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pId",
                rootPId: 0
            }
        },
        check: {
            enable: true
        }

    };
    // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
    var zNodes = [
        {id: 1, pId: 0, name: "父节点1"},
        {id: 11, pId: 1, name: "子节点1", checked: true},
        {id: 12, pId: 1, name: "子节点2"}
    ];

    //初始化树
    $(document).ready(function () {
        zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);

        //展开树形结构
        zTreeObj.expandAll(true);
    });
</SCRIPT>


<div>
    <ul id="treeDemo" class="ztree"></ul>
</div>


<button id="btn">提交</button>

<script>
    $("#btn").click(function () {
        //获取勾选的节点
        var nodes = zTreeObj.getCheckedNodes(true);
        alert(nodes.length);
    })
</script>

</body>
</html>